package com.bafenyi.zh.bafenyilib.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import org.jetbrains.annotations.NotNull;

import java.util.Properties;

import butterknife.ButterKnife;




public abstract class BFYBaseFragment extends Fragment {


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(getBaseLayoutId(), container, false);
    }


    @Override
    public void onViewCreated(@NotNull View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        ButterKnife.bind(this, view);

        initBaseView(savedInstanceState);
    }

    @LayoutRes
    protected abstract int getBaseLayoutId();

    protected abstract void initBaseView(Bundle savedInstanceState);

    /**
     * 内部方法
     * */
    public interface FragmentHiddenListener {
        void onResult(boolean is_show);
    }
    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hiddenListener != null) {
            hiddenListener.onResult(!hidden);
        }
    }
    private FragmentHiddenListener hiddenListener;
    public void is_hidden(FragmentHiddenListener hiddenListener){
        this.hiddenListener = hiddenListener;
    }
}
